/**
 * 
 */
package edu.umd.clip.lm.model.training.metrics;

import org.w3c.dom.*;

import edu.umd.clip.lm.model.training.ContextVariable;
import edu.umd.clip.lm.model.training.ContextVariableStats;

/**
 * @author Denis Filimonov <den@cs.umd.edu>
 *
 */
public abstract class ContextVariableMetrics implements ContextVarStatUser {
	private final String name;
	
	public static final String NAME_ATTR = "name";
	
	public void saveXML(Element elem) {
		elem.setAttribute("class", getClass().getCanonicalName());
		elem.setAttribute(NAME_ATTR, name);
	}
	
	public ContextVariableMetrics(Element elem) {
		name = elem.getAttribute(NAME_ATTR);
	}
	
	public ContextVariableMetrics(String name) {
		this.name = name;
	}
	
	public abstract double computeScore(ContextVariable ctxVar, ContextVariableStats stat);

	public String getName() {
		return name;
	}
}
